<template>
	<view class="withdraw-container">
		<view class="withdraw-content">
			<u-form>
				<u-form-item label="提现至：" label-width="240">
					<u-input v-model="form.withdraw" placeholder="微信钱包（绑定的微信）" clearable />
				</u-form-item>
				<u-form-item label="提现金额： ¥" label-width="240">
					<view class="withdraw-amount">
						<u-input v-model="amount" placeholder="填写提现金额" />
					</view>
				</u-form-item>
			</u-form>
		</view>
		<view class="withdraw-info">
			<text>当前零钱：{{ form.balance.toFixed(2) }} 全部提现</text>
			<text>最低提现金额：{{ form.minAmount.toFixed(2) }}</text>
			<text>手续费：{{ form.fee.toFixed(2) }}%</text>
		</view>
		<u-button type="primary" @click="submitWithdraw" class="withdraw-button" shape="circle">提交</u-button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				form: {
					withdraw: '',
					amount: '',
					balance: 0.00,
					minAmount: 1.00,
					fee: 0.00
				}

			};
		},
		methods: {
			submitWithdraw() {
				if (this.amount === '') {
					uni.showToast({
						title: '请输入提现金额',
						icon: 'none'
					});
					return;
				}
				if (parseFloat(this.amount) < this.minAmount) {
					uni.showToast({
						title: `最低提现金额为${this.minAmount}`,
						icon: 'none'
					});
					return;
				}
				// 提交提现请求的逻辑代码
				console.log('提现金额:', this.amount);
				uni.showToast({
					title: '提现成功',
					icon: 'success'
				});
			}
		}
	};
</script>

<style>
	.withdraw-container {
		padding: 0 20px;
	}

	.withdraw-header {
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-bottom: 20px;
	}

	.title {
		font-size: 20px;
		font-weight: bold;
	}

	.withdraw-content {
		/* background-color: #f8f8f8f8; */
		padding: 20px 0;
		border-radius: 8px;
	}

	.withdraw-to {
		font-size: 16px;
		color: #555;
	}

	.withdraw-amount {
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-bottom: 20px;
	}

	.withdraw-info {		
		font-size: 14px;
		color: #888;
		margin-bottom: 20px;
		display: flex;
	  flex-direction: column;
	}

	.withdraw-all {
		color: #007aff;
	}

	.withdraw-button {
		width: 100%;
		margin-top: 20px;
	}
</style>